<template>
  <div>
    <NavBar>
      <div slot="left" @click="$router.back()">
        <div class="back"></div>
      </div>
      <div slot="center" class="title-item">
        <div class="title" v-for="(item, index) in titles" @click="itemClick(index)" :class="{active: index === currentIndex}">
          {{item}}
        </div>
      </div>
    </NavBar>
  </div>
</template>

<script>
import NavBar from "@/components/common/navbar/NavBar";
import index from "@/api";
export default {
  name: "DetailNavBar",
  props: {
    titles: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  components: {
    NavBar
  },
  data() {
    return {
      currentIndex: 0
    }
  },
  methods: {
    itemClick(index) {
      this.currentIndex = index
      this.$emit('tabItemClick', index)
    }
  }
}
</script>

<style scoped>
  .back {
    margin: 14px 0 0 10px;
    width: 15px;
    height: 15px;
    border: 1px solid transparent;
    border-top-color: black;
    border-right-color: black;
    transform: rotate(-135deg);
  }
  .title-item {
    display: flex;
    font-size: 14px;
  }
  .title {
    flex: 1;
  }
  .active {
    color: var(--color-high-text);
  }
</style>
